<template>
  <div class="search-container">
    <div class="search-box">
      <input 
        type="text" 
        v-model="searchQuery" 
        placeholder="搜索..." 
        @keyup.enter="handleSearch"
      />
      <button @click="handleSearch">搜索</button>
    </div>
    <div class="quick-links">
      <a 
        v-for="link in quickLinks" 
        :key="link.id" 
        :href="link.url" 
        target="_blank"
        class="quick-link"
      >
        {{ link.name }}
      </a>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'

const searchQuery = ref('');
const emit = defineEmits(['search']);

const quickLinks = ref([
  { id: 1, name: 'ChatGPT', url: 'https://chat.openai.com' },
  { id: 2, name: 'OpenAI', url: 'https://openai.com' },
  { id: 3, name: 'GitHub', url: 'https://github.com' },
  { id: 4, name: 'Google', url: 'https://google.com' },
  { id: 5, name: 'Stack Overflow', url: 'https://stackoverflow.com' },
  { id: 6, name: 'MDN', url: 'https://developer.mozilla.org' },
]);

const handleSearch = () => {
  emit('search', searchQuery.value);
};
</script>

<style scoped>
.search-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
  padding: 20px;
}

.search-box {
  display: flex;
  gap: 10px;
  width: 100%;
  max-width: 600px;
}

input {
  flex: 1;
  padding: 10px 15px;
  border: 2px solid #e0e0e0;
  border-radius: 4px;
  font-size: 16px;
  transition: border-color 0.3s;
}

input:focus {
  outline: none;
  border-color: #007bff;
}

button {
  padding: 10px 20px;
  background-color: #007bff;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.3s;
}

button:hover {
  background-color: #0056b3;
}

.quick-links {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 600px;
}

.quick-link {
  text-decoration: none;
  color: #666;
  padding: 6px 12px;
  border-radius: 16px;
  background-color: #f0f0f0;
  font-size: 14px;
  transition: all 0.3s ease;
}

.quick-link:hover {
  background-color: #007bff;
  color: white;
  transform: translateY(-2px);
}
</style> 